package ThreadDemo;

/**
 * @Author Zhang Chao
 * @Date 2021/5/27 16:54
 * @Version 1.0
 */
public class ProducerThread extends Thread{

    //属性

    //仓库属性
    private MyStack myStack;


    //行为
    public ProducerThread(MyStack myStack) {
        this.myStack = myStack;
    }

    @Override
    public void run() {
        //super.run();
        for( ; ; ){
            //生产着生产一个产品
            Goods goods = new Goods("商品X",10.5);
            //生产着将产品入库
            myStack.push(goods);
            //休眠1000ms
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    }
}
